The processing and rendering of graphics images is an important feature of modern computing systems. In image processing, mathematical procedures are implemented to render, or draw, graphic primitives, e.g., triangles or rectangles, on a display to produce desired visual images. Real time graphics processing is based on the high-speed processing of graphic primitives to produce visually pleasing moving images.
To enhance image quality, shadow generation techniques such as stenciled shadow volumes have been introduced to add realistic shadows to rendered images. The stenciled shadow volume technique depends on the use of a stencil buffer, described in more detail further below.
Graphics are typically designed by graphics designers who use application program interfaces (APIs), which are standardized software interfaces, to render desired images that can be run on multiple platforms, operating systems, and hardware. Examples of APIs include the Open Graphics Library (OpenGL®) and D3D™. This enables graphic designers to design graphics without knowing any of the specifics regarding the system hardware or how their commands will be implemented. Application program interfaces (APIs) are widely accepted, powerful, and are good vehicles for implementing features such as those of the present invention.
When a graphics image is rendered each pixel of that image is given a set of values that are stored in a buffer memory and that are used to “display” the pixel. For example, each pixel can have a color value that is stored in a color buffer and a depth value that is stored in a depth (Z) buffer memory.
In addition to color and depth buffer memories, each pixel can also have an entry in a stencil buffer. A stencil buffer is a memory comprised of stencil registers that can control the update of a pixel. In the simplest case, the stencil buffer is used to limit the area of rendering (stenciling). In particular, the stencil buffer enables or disables drawing to the rendering target surface on a pixel-by-pixel basis. At its most fundamental level, it enables applications to mask sections of the rendered image so that they are not displayed.
Typical uses of stencil buffers include defining regions for masking pixel updates, constructive solid geometry, and adding shadows. For example, if portions of a “background” are to show through windows, the stencil registers for the background that will show can be given values while the stencil registers for other areas can be cleared. The value of the stencil registers can then be compared to a threshold value and used to mask-out areas that are not to show through (or mask-in the areas that are). More advanced usage of the stencil buffer makes use of the strong connection between the depth buffer and the stencil buffer in the rendering pipeline. For example, stencil values can be automatically increased/decreased for every pixel that fails or passes the depth test. Related to stencil buffers is a stencil test, which conditionally discards a fragment based on the outcome of a comparison between the value in the stencil buffer at a particular location and a reference value.
As previously noted a stencil buffer can also be used to add shadows. Shadows can enhance an image by producing a more natural-looking image. Since graphic shadows correspond to real world shadows, graphic shadows represent the effects of shading caused by surfaces that block light. Since a given image may have both multiple light sources and multiple light-blocking surfaces the shadow value of each pixel depends on the shading produced by all of the light sources and all of the light-blocking surfaces. Images with convincing shadows can be produced using one or more shadow algorithms that store values in a stencil buffer. Most shadow algorithms “turn off” the light sources, determine a base shadow value for each pixel, then selectively turn on the individual light sources, determine the shadow value produced by each light source, and then blend the result to produce a composite shadow value for each pixel. On embedded graphics hardware with OpenGL ES 2.0 standard, for example, the processing of shadows is often the slowest component, even with simple fragment shaders.
Thus, in order to render an image, all fragments (OR PIXELS?) of the image need to be processed. However, in consecutive image frames in which only a portion of the fragments in the image frames are changing and which require instant visual feedback, such as automotive cluster instrument digital speedometer rendering, all the fragments in the image frames, up until now, needed to be processed.
The foregoing overview has been presented in a simplified manner for clarity. Implementing the foregoing is often performed using graphics design packages. Such packages enable a graphics designer to specify numerous editing and formatting attributes, including shadow algorithms and other uses of the stencil buffer.
When using a stencil buffer, such as when implementing a shadow algorithm, it is typically necessary to first clear the stencil registers. For example, when determining the effects of light sources on the stencil value of each pixel it is typically necessary to clear the stencil buffer multiple times, e.g., once for each light source. By clearing it is meant setting the value of cleared stencil registers to some predetermined value, often, but not always, 00hex. While clearing a stencil register is not particularly difficult, say by writing a predetermined value to each stencil register, writing that value to each stencil register is a fairly slow process given that millions of stencil registers might exist. Having to do so multiple times, such as when shadow rendering, can become excessively time consuming. Additionally, stencil-only frame buffer clears are increasingly common as 3D applications are now using rendering algorithms such as stenciled shadow volume rendering for multiple light sources in a single frame, recent “soft” stenciled shadow volume techniques, and stencil-based constructive solid geometry techniques. In such algorithms there are multiple stencil buffer clears for each depth buffer clear.
In view of the foregoing, a method of effectively clearing stencil registers at high speed would be beneficial. Also beneficial would be methods of enabling a graphics designer to control the clearing of stencil registers such that the use of the stencil buffer is not negatively impacted. Also beneficial would be a high speed system and method for effectively clearing stencil registers such that numerical algorithms that use the stencil buffer are not negatively impacted.
The aim of the present invention is thus to reduce GPU fragment processing for consecutive image frames, with each image frame being defined by a scene graph and with each object within each image frame having an associated geometric bounding volume. In particular, in real-time applications, wherein only relatively minor parts or objects of an image frame change, when compared to a previous image frame, the performance is increased if only those minor parts are re-rendered.
A scene graph is a general data structure commonly used by graphics editing applications and modern computer games. The scene graph is a structure that arranges the logical and often (but not necessarily) spatial representation of a graphics image. A scene graph is a collection of nodes in a graph or tree structure. A node may have many children but often only a single parent, with the effect of a parent applied to all its child nodes; an operation performed on a group automatically propagates its effect to all of its members. In many programs, associating a geometrical transformation matrix at each group level and concatenating such matrices together is an efficient and natural way to process such operations. A common feature, for instance, is the ability to group related shapes/objects into a compound object that can then be moved, transformed, selected, etc. as easily as a single object.